package com.dd.census.emums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum DictionaryGroupEnum {

	SEX("SEX", "性别"), EDUCATION("EDUCATION", "学历");

	private String desc;
	private String type;

	DictionaryGroupEnum(String type, String desc) {
		this.type = type;
		this.desc = desc;
	}

	private String getDesc() {
		return desc;
	}

	private String type() {
		return this.type;
	}

	public static String getValue(String type) {
		DictionaryGroupEnum[] carTypeEnums = values();
		for (DictionaryGroupEnum carTypeEnum : carTypeEnums) {
			if (carTypeEnum.type().equals(type)) {
				return carTypeEnum.desc;
			}
		}
		return null;
	}

	public static String getType(String desc) {
		DictionaryGroupEnum[] carTypeEnums = values();
		for (DictionaryGroupEnum carTypeEnum : carTypeEnums) {
			if (carTypeEnum.desc.equals(desc)) {
				return carTypeEnum.type();
			}
		}
		return null;
	}

	/**
	 * 转换为list
	 */
	public static List toList() {
		List list = new ArrayList();
		for (DictionaryGroupEnum _enum : DictionaryGroupEnum.values()) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("name", _enum.name());
			map.put("value", _enum.getDesc());
			list.add(map);
		}
		return list;
	}
}
